1 00:00:00,630 --> 00:00:03,140 Hello and welcome to feed you. 2 00:00:03,330 --> 00:00:13,970 We are going to be adding the javascript functionality that will make the come to tool work inside me 3 00:00:13,980 --> 00:00:14,970 hastier mail. 4 00:00:14,970 --> 00:00:18,640 I've already got a reference to the external javascript. 5 00:00:18,690 --> 00:00:21,700 I've called it hitch converter Duchess. 6 00:00:21,840 --> 00:00:29,400 I'm not going to go ahead and at the farm so I click on file and then you can I'm going to save this 7 00:00:29,400 --> 00:00:35,760 file and save it has inside the same directory and I'm going to call it here. 8 00:00:35,780 --> 00:00:40,050 Convert to dot g s. 9 00:00:41,600 --> 00:00:42,990 I'll save that. 10 00:00:43,170 --> 00:00:49,380 And that will become my javascript file kisses on the bottom right says javascript. 11 00:00:49,380 --> 00:00:53,640 I've already pre staged the javascript code. 12 00:00:53,800 --> 00:00:59,030 Um just cannot add that in and gone through the code line by line. 13 00:00:59,330 --> 00:01:04,020 So this is my javascript so on line run. 14 00:01:04,130 --> 00:01:13,000 I've got a document called get elemen by the method and I am passing into that parameter. 15 00:01:13,220 --> 00:01:20,610 The submit inputs of go into the hastier month here we've got an idea code submit. 16 00:01:20,930 --> 00:01:34,090 That is the I.D. I'm passing into this and then I am attaching the ADD event list now to that. 17 00:01:34,370 --> 00:01:38,180 Okay so this is busy this add event list. 18 00:01:38,240 --> 00:01:46,340 Basically is used to attach an event handler to the document. 19 00:01:46,580 --> 00:01:54,480 So I've now attached an event handler to the document and also attached click event. 20 00:01:54,480 --> 00:01:56,100 See this is the click event. 21 00:01:56,330 --> 00:02:05,820 So when someone clicks on this submit button it would trigger this function here. 22 00:02:05,840 --> 00:02:10,430 Cord high it converts to this function called Hide. 23 00:02:10,430 --> 00:02:19,430 Converter is the function I have defined here on line 3 so anything between the opening curly braces 24 00:02:19,810 --> 00:02:29,080 and the ending calibrators is a function that will execute when someone clicks on the submit button. 25 00:02:29,150 --> 00:02:31,250 So the click is event. 26 00:02:31,540 --> 00:02:39,770 The add in bit list now is the event had handler that will listen out for the Click event so the moment 27 00:02:39,830 --> 00:02:41,740 it listens out and hit. 28 00:02:41,990 --> 00:02:47,610 Here's a click to call this function here which is a function. 29 00:02:47,630 --> 00:02:51,340 I'm defining here saw line 3. 30 00:02:51,350 --> 00:02:54,340 I started the definition of the function. 31 00:02:54,590 --> 00:03:00,640 You define a function by typing the word function followed by the name you want to call the function 32 00:03:00,970 --> 00:03:03,120 and then you atash. 33 00:03:03,190 --> 00:03:06,250 Apparently this is opening and closing parentheses. 34 00:03:06,290 --> 00:03:14,750 You also have to have typed openly and quickly braces inside the Culebra it is where you had the logic 35 00:03:14,840 --> 00:03:21,500 for code for functions so anything you want a function to do has to be between the curly braces. 36 00:03:21,800 --> 00:03:27,760 You can also pass in arguments inside parenthesis if you want to perform on our parent. 37 00:03:27,760 --> 00:03:37,610 This is an empty line full I have defined a variable called feet and set that to your cause or parse 38 00:03:37,790 --> 00:03:47,870 it passed into basically is a function that passes its drink and returns an integer. 39 00:03:48,230 --> 00:03:53,570 Okay that's what the parsing than inside the parentheses for this parse it. 40 00:03:53,660 --> 00:04:00,920 I have the document get elemen by iteam method and am in Ft. 41 00:04:01,100 --> 00:04:10,460 Which you can get here from this is a mail import So whatever import is entered there is what I am referring 42 00:04:10,460 --> 00:04:11,640 to here. 43 00:04:11,800 --> 00:04:18,940 And you know it is a matter attaching a value so whatever input is entered the value of that we going 44 00:04:18,950 --> 00:04:22,680 to multiply that by 12. 45 00:04:22,850 --> 00:04:26,990 One inch is equivalent to. 46 00:04:27,560 --> 00:04:32,250 If you want to find the value of an inch you multiply the value in Ft. 47 00:04:32,350 --> 00:04:33,020 Time. 48 00:04:33,170 --> 00:04:33,820 12. 49 00:04:33,980 --> 00:04:37,400 So whatever value you entering as ft. 50 00:04:37,580 --> 00:04:44,980 You have to monts imply that by off to give you the value of an inch. 51 00:04:45,260 --> 00:04:56,570 So for example if I had a value of six as my feet I would need to moduli that by 12 to convert that 52 00:04:56,660 --> 00:04:58,200 in two inches. 53 00:04:58,670 --> 00:05:00,690 And then here a variable called inches. 54 00:05:00,710 --> 00:05:08,150 Again I'm using the parse into function and I'm using to document or get element a D passing in the 55 00:05:08,150 --> 00:05:09,270 inches I did. 56 00:05:09,290 --> 00:05:12,400 Which you can get from here inside this input. 57 00:05:12,680 --> 00:05:22,970 So passing in that again I am grabbing what ever a value is entered into that input here on line 7. 58 00:05:22,970 --> 00:05:31,250 I have got a variable called centimetres and upsetting that to equal so the value of the FT variable 59 00:05:32,150 --> 00:05:39,880 plus inches multiply by 2.5 for 1 inch. 60 00:05:40,890 --> 00:05:44,880 Valennes to 2.5 for senti meters. 61 00:05:45,180 --> 00:05:45,960 Okay. 62 00:05:46,020 --> 00:05:54,040 So all you need is in parenthesis is that we have to do this couple on first with the parenthetic it 63 00:05:54,040 --> 00:06:01,170 will do the multiplication first because his higher up in order than the plot so right now writing this 64 00:06:01,210 --> 00:06:04,190 imperent this is a means to do this first. 65 00:06:04,200 --> 00:06:13,020 So it will add whatever value quote for my feet it will then add that to the inches and then multiply 66 00:06:13,020 --> 00:06:17,110 that by 2.5 for line 8. 67 00:06:17,120 --> 00:06:25,120 I've got a variable called N and upsetting that to a devalue of the centimetre variable and then in 68 00:06:25,140 --> 00:06:29,220 the attaching that to this to fixed metal. 69 00:06:29,220 --> 00:06:40,980 This to fix is a method that converts in number into his drink and you can also keep a specified number 70 00:06:40,980 --> 00:06:42,390 of decimals. 71 00:06:42,420 --> 00:06:45,500 In this case have you just passed saying the value of zero. 72 00:06:45,640 --> 00:06:51,630 Is going to keep the zero decimal places so if you want to have two decimal places you have to pass 73 00:06:51,630 --> 00:06:53,610 in that value of two. 74 00:06:53,910 --> 00:06:56,340 Inside that parenthesis. 75 00:06:56,940 --> 00:07:02,430 So we are converting feet into inches by multiply and by 12. 76 00:07:02,430 --> 00:07:08,700 Here and there and we are converting the value here. 77 00:07:08,710 --> 00:07:11,980 We're converting to get the value a centimetre. 78 00:07:12,120 --> 00:07:17,940 We add undervaluing feet plus inches is variable feet plus inches. 79 00:07:17,940 --> 00:07:26,830 Our models apply in there by 2.5 4 because an inch is equivalent of 2.5 4 centimetres. 80 00:07:26,970 --> 00:07:33,410 Here is the still fixed method which converts in number into his drink can have past 10. 81 00:07:33,420 --> 00:07:36,540 The value of several decimal places. 82 00:07:36,670 --> 00:07:38,210 Line 12. 83 00:07:38,700 --> 00:07:44,480 This is where will be hard put to results so we grab a middle document or get to eliminate part D and 84 00:07:44,520 --> 00:07:54,210 D D where grabbing is a results idea which is this idea here to grab in that we are replacing the content 85 00:07:54,840 --> 00:07:59,700 with the inner email and with setting that to the value of. 86 00:07:59,790 --> 00:08:01,630 Which is this value here. 87 00:08:01,860 --> 00:08:08,910 So whether VAT is variable output is going to display that inside this result div. 88 00:08:09,150 --> 00:08:10,020 So that's it. 89 00:08:10,020 --> 00:08:14,440 I am going to save that and then we can test to see everything work. 90 00:08:14,710 --> 00:08:21,350 I'm going to open up the directory and double click on the hatim of file. 91 00:08:22,020 --> 00:08:23,610 Okay so this is our hide. 92 00:08:23,610 --> 00:08:24,190 Convert. 93 00:08:24,220 --> 00:08:33,450 I'm just going to type in around on it and see if 5 feet so 5 feet 10 inches. 94 00:08:33,540 --> 00:08:35,840 Convert that into a centimetre. 95 00:08:35,850 --> 00:08:38,400 Give you a hundred and seventy it's intermittent. 96 00:08:38,400 --> 00:08:41,450 Let's try a couple more. 97 00:08:41,800 --> 00:08:54,480 2 6 2 6 5 6 feet and 5 inches gives you a hundred and ninety six centimetre would do one more. 98 00:08:54,760 --> 00:09:02,000 Let's say 5 3 convert give you a hundred and sixty centimetre. 99 00:09:02,130 --> 00:09:07,320 So we've got our height converter working properly so that's it for this lecture. 100 00:09:07,330 --> 00:09:10,690 If you have any issues please to let me know. 101 00:09:10,710 --> 00:09:12,900 This concludes this project. 102 00:09:12,900 --> 00:09:15,000 Thanks for watching and bye for now.